package com.dragon.client.controller.contract;

import com.dragon.common.model.ResponseData;
import com.dragon.logical.service.contract.IContractFitService;
import com.dragon.repository.domain.dto.ContractFitDTO;
import com.dragon.repository.domain.vo.ContractFitVO;
import com.dragon.repository.entity.ContractFit;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 合同设置 前端控制器
 * </p>
 *
 * @author sy
 * @since 2023-11-08
 */
@RestController
@RequestMapping("contractFit")
@Api(tags = "合同设置")
public class ContractFitController {

    @Autowired
    IContractFitService service;


    @PostMapping("update")
    @ApiOperation(value = "修改合同列表")
    public ResponseData updateFit(@RequestBody @Validated(Update.class) ContractFitVO vo){
        service.updateFit(ContractFitVO.convert(vo));
        return ResponseData.success();
    }

    @PostMapping("detail")
    @ApiOperation(value = "详情")
    public ResponseData<ContractFitDTO> detailOneById(
            @ApiParam(name = "id", value = "主表id", required = true, type = "int")
            @RequestParam Integer id){
        ContractFit contractFit = service.detailOne(id);
        return ResponseData.success(ContractFitDTO.convert(contractFit));
    }

}
